home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 001 / pibt40s1.arc / FASTCHNG.MOD < prev    next >
Text File  |  1987-03-17  |  5KB  |  113 lines

  1. (*----------------------------------------------------------------------*)
  2. (*       Fast_Change_Params --- fast change of communications params.   *)
  3. (*----------------------------------------------------------------------*)
  4.  
  5. PROCEDURE Fast_Change_Params;
  6.  
  7. (*----------------------------------------------------------------------*)
  8. (*                                                                      *)
  9. (*     Procedure:  Fast_Change_Params                                   *)
  10. (*                                                                      *)
  11. (*     Purpose:    Fast change of communications params                 *)
  12. (*                                                                      *)
  13. (*     Calling Sequence:                                                *)
  14. (*                                                                      *)
  15. (*        Fast_Change_Params;                                           *)
  16. (*                                                                      *)
  17. (*                                                                      *)
  18. (*      Remarks:                                                        *)
  19. (*                                                                      *)
  20. (*         This routine is useful is making a fast switch between       *)
  21. (*         the parameter values needed by XMODEM and those required     *)
  22. (*         by the remote host.                                          *)
  23. (*                                                                      *)
  24. (*----------------------------------------------------------------------*)
  25.  
  26. CONST
  27.    Comm_Parities  : ARRAY[ 1 .. 5 ] OF CHAR    = ( 'N','E','O','M','S' );
  28.    Comm_Data_Bits : ARRAY[ 1 .. 5 ] OF INTEGER = (  8,  7,  7,  7,  7  );
  29.    Baud_Rates     : ARRAY[ 1 .. 5  ] OF INTEGER
  30.                     = ( 300, 1200, 2400, 9600, 19200 );
  31.    Letters        : ARRAY[1..25] OF CHAR
  32.                     = ( 'a','f','k','p','u',
  33.                         'b','g','l','q','v',
  34.                         'c','h','m','r','w',
  35.                         'd','i','n','s','x',
  36.                         'e','j','o','t','y'  );
  37.  
  38. VAR
  39.    I               : INTEGER;
  40.    J               : INTEGER;
  41.    Let             : INTEGER;
  42.    Local_Save      : Saved_Screen_Ptr;
  43.    OK_Choice       : BOOLEAN;
  44.    Ch              : CHAR;
  45.  
  46. BEGIN (* Fast_Change_Params *)
  47.                                    (* Save screen image        *)
  48.    Save_Screen( Local_Save );
  49.                                    (* Draw frame around screen *)
  50.  
  51.    Draw_Menu_Frame( 1, 5, 79, 14, Menu_Frame_Color, Menu_Title_Color,
  52.                     Menu_Text_Color, 'Change communications settings' );
  53.  
  54.    Window( 2, 6, 78, 13 );
  55.                                    (* Display params to choose from *)
  56.    Let := 0;
  57.  
  58.    FOR I := 1 TO 5 DO
  59.       BEGIN
  60.          GoToXY( 2 , I );
  61.          FOR J := 1 TO 5 DO
  62.             BEGIN
  63.                Let := Let + 1;
  64.                TextColor( Menu_Text_Color_2 );
  65.                WRITE( Letters[ Let ] );
  66.                TextColor( Menu_Text_Color  );
  67.                WRITE( ') ' );
  68.                WRITE( Baud_Rates[J]:5,',',Comm_Data_Bits[I],',',
  69.                       Comm_Parities[I],',1 ' );
  70.             END;
  71.       END;
  72.                                    (* Get new params *)
  73.    REPEAT
  74.       GoToXY( 2 , 7 );
  75.       TextColor( Menu_Text_Color_2 );
  76.       WRITE ( 'Enter letter corresponding to new parameters or ESC to quit: ');
  77.       TextColor( Menu_Text_Color );
  78.       Read_Kbd( Ch );
  79.       Ch := UpCase( Ch );
  80.       OK_Choice := ( Ch = CHR( ESC ) ) OR
  81.                    ( Ch = CHR( CR  ) ) OR
  82.                    ( ( ORD( Ch ) >= ORD( 'A' ) ) AND
  83.                      ( ORD( Ch ) <= ORD( 'Y' ) ) );
  84.       IF ( NOT OK_Choice ) THEN
  85.          Menu_Beep;
  86.    UNTIL ( OK_Choice );
  87.                                    (* Get parameters corresponding *)
  88.                                    (* to choice.                   *)
  89.  
  90.    IF ( ( Ch <> CHR( ESC ) ) AND ( Ch <> CHR( CR ) ) ) THEN
  91.       BEGIN
  92.  
  93.          Let := ORD( Ch ) - ORD( 'A' );
  94.          J   := ( Let DIV 5 ) + 1;
  95.          I   := ( Let MOD 5 ) + 1;
  96.  
  97.          Baud_Rate := Baud_Rates    [J];
  98.          Parity    := Comm_Parities [I];
  99.          Data_Bits := Comm_Data_Bits[I];
  100.          Stop_Bits := 1;
  101.                                    (* Reset the port *)
  102.  
  103.          Async_Reset_Port( Comm_Port, Baud_Rate, Parity, Data_Bits, Stop_Bits );
  104.  
  105.          Reset_Comm_Port := TRUE;
  106.  
  107.       END;
  108.                                    (* Restore previous screen *)
  109.    Restore_Screen( Local_Save );
  110.    Reset_Global_Colors;
  111.  
  112. END   (* Fast_Change_Params *);
  113.